public class Book {
    private String title;
    private String author;
    private int price;
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        if (title != null && title.length() >= 1 && title.length() <= 10) {
            this.title = title;
        } else {
            System.out.println("书名长度需在1-10之间，赋值失败");
        }
    }
    public String getAuthor() {
        return author;
    }
    public void setAuthor(String author) {
        if (author != null && author.length() >= 1 && author.length() <= 5) {
            this.author = author;
        } else {
            System.out.println("作者长度需在1-5之间，赋值失败");
        }
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        if (price >= 10 && price <= 100) {
            this.price = price;
        } else {
            System.out.println("价格需在10-100之间，赋值失败");
        }
    }
    public Book(String title, String author, int price) {
        setTitle(title);
        setAuthor(author);
        setPrice(price);
    }
    public void printInfo() {
        System.out.printf("书名：《%s》 作者：%s 价格：%d\n", title, author, price);
    }
}
